//
//  BanBu_BubbleCell.m
// Halfarea
//
//  Created by Wang Xj on 14-3-3.
//
//

#import "BanBu_BubbleCell.h"

@implementation BanBu_BubbleCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initImageView];
        self.backgroundColor = [UIColor clearColor];
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)initImageView
{
    self.backgroundColor = [UIColor clearColor];
    
    if (!self.imageView1)
    {
        self.imageView1 = [[[UIImageView alloc]initWithFrame:CGRectMake(15, 5, 130, 90)] autorelease];
        self.imageView1.tag = 1;
    }
    self.imageView1.userInteractionEnabled = YES;
    
    if (!self.imageView2)
    {
        self.imageView2 = [[[UIImageView alloc]initWithFrame:CGRectMake(175,5, 130, 90)] autorelease];
        self.imageView2.tag = 2;
    }
    self.imageView2.userInteractionEnabled = YES;
    
    
    
    //添加点击事件
    UITapGestureRecognizer * tap1 = [[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(selectBubble:)] autorelease];
    UITapGestureRecognizer * tap2 = [[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(selectBubble:)] autorelease];
    [self.imageView1 addGestureRecognizer:tap1];
    [self.imageView2 addGestureRecognizer:tap2];
    
    [self addSubview:self.imageView1];
    [self addSubview:self.imageView2];
    self.imageView1.hidden = NO;
    self.imageView2.hidden = NO;
}

-(void)selectBubble:(UITapGestureRecognizer *)tap
{
    if ([_delegate respondsToSelector:@selector(menuShow:tableCell:)])
    {
        [_delegate menuShow:tap.view tableCell:self];
    }
}

-(void)dealloc
{
    [_imageView1 release],_imageView1=nil;
    [_imageView2 release],_imageView2=nil;
    [_bubbleID1 release],_bubbleID1 = nil;
    [_bubbleID2 release],_bubbleID2 = nil;
    [super dealloc];
}

@end
